<?php
/**
* Created by PhpStorm.
 * User: Administrator
* Date: 2017/8/15
* Time: 16:48
*/


// 自定义验证
$data['user_name'] = input('post.user_name');
$data['UserEmail'] = input('post.UserEmail');
$data['UserPassward'] = input('post.UserPasswd');

$rule=[

    ['user_name', 'require|max:10','名字不能为空|名字不能超过十位'],
    ['UserEmail', 'require|email','邮箱不能为空|邮箱格式不正确'],
    ['UserPassward','require','密码不能为空']
];

$validate = new Validate($rule);
$result   = $validate->check($data);
if(!$result){
    return $this->error($validate->getError());
}else{
    if ($user->save($data)) {
        return $this->success('注册成功','');
    } else {
        return $this->error('注册失败');
    }
}